package rush.rushcampus.mapper;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;
import rush.rushcampus.entity.Article;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author rush
 * @since 2024-06-11
 */

@Mapper
public interface ArticleMapper extends BaseMapper<Article> {
    // 使用数据库的原子操作增加 view 字段


    @Update("UPDATE article SET view = view + 1 WHERE id = #{articleId}")
    void incrementArticleViewById(Long articleId );
    @Update("UPDATE found SET view_count = view_count + 1 WHERE id = #{foundId}")
    void incrementFoundViewById(Long foundId);
    @Update("UPDATE idle SET view_count = view_count + 1 WHERE id = #{articleId}")
    void incrementIdleById(Long articleId);
}
